# definitions
LIBRARY = libmath
SRC = quaternion.cpp transform.cpp smooth.cpp crc.cpp random.cpp filter.cpp ntt.cpp natural.cpp

# definitions
CPPFLAGS = -O2 @gcc.conf -MMD -MP -DNDEBUG
LDFLAGS = -O2

# all
all: $(LIBRARY).a html/index.html test

html/index.html: $(LIBRARY).a
	doxygen Doxyfile >/dev/null

clean:
	rm -f $(LIBRARY).a *.o

# library functions
$(LIBRARY).a: $(SRC:%.cpp=%.o)
	rm -f $@
	ar qc $@ $(SRC:%.cpp=%.o)

# library
test: test.o $(LIBRARY).a
	$(CXX) $(LDFLAGS) -o $@ $< $(LIBRARY).a
	./test >/tmp/$$PPID.out
	diff -s test.out /tmp/$$PPID.out

#dependencies
-include $(SRC:%.cpp=%.d) test.d
